<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;
use app\model\not_del\UserModel as NotDelUserModel;

/**
 * 心理咨询-排班时间
 */
class ConsultTimeModel extends BaseModel
{
    protected $name = 'consult_time';

    /**
     * 关联咨询师
     * @return BelongsTo
     */
    public function consult(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'consult_id')->bind([
            'consult_name' => 'name'
        ]);
    }

    /**
     * 关联用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'uid')->bind([
            'user_name' => 'name',
            'user_sex' => 'sex',
            'user_age' => 'age',
            'user_department_id' => 'department_id'
        ]);
    }

    /**
     * 关联部门-部门名称
     * @return BelongsTo
     */
    public function departmentName(): BelongsTo
    {
        return $this->belongsTo('DepartmentModel','department_id')->bind(['department_name'=>'name']);
    }
}